function findMedianSortedArrays(nums1: number[], nums2: number[]): number {
  // 合并 concat
  // 排序 标准快排
  // 判断是否余数 奇偶
  if(nums1 == null || nums1.length == 0 && nums2 == null || nums1.length == 0) return 0;
  if(nums1 == null || nums1.length == 0){
      
      return jg(nums2)
  }else if(nums2 == null || nums1.length == 0){
      
       
       return jg(nums1)
  }else{
      let num3:number[] = []
       num3 = nums1.concat(nums2);
      num3 = normalSort(num3,0,num3.length)
      console.log(num3)
      let mid = Math.floor(num3.length / 2)
      return jg(num3)
      
  }
  
};
function jg(arr:number[]):number{
  // if(arr == null || arr.length ==0)return 0;
  if(arr.length == 1)return arr[0]
  let num = arr.length % 2
  let mid = Math.floor(arr.length /2)
  if(num == 0){
      return Number((arr[mid]+arr[mid-1])/2)
  }else{
       return Number(arr[mid])
  }
}
function exchange(arr:number[],a:number,b:number):any{
  let mid = arr[a]
  arr[a] = arr[b]
  arr[b] = mid
}
function normalSort(arr:number[],begin:number,end:number):any{
  if(arr == null || arr.length ==0)return [];
  let left = begin;
  let right = end; 
  do{
      do left++;while(left<right && arr[left] < arr[begin])
      do right;while(left<right && arr[right] > arr[begin])
      if(left<right)exchange(arr,left,right)
  }while(left < right)
  // exchange
  let midindex = left == right?right:right - 1;
  exchange(arr,begin,midindex)
  normalSort(arr,begin,midindex)
  normalSort(arr,midindex+1,end)
}



findMedianSortedArrays